package com.gree.fms.processor.convertors;

import com.gree.fms.processor.annotations.RocketMQMessageListenerExpand;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Names;

/**
 * @author joyce
 */
public class ExpandToMessageListenerConvertor {

    public static List<JCTree.JCExpression> converter(TreeMaker treeMaker, Names names, RocketMQMessageListenerExpand source) {
        return List.of(
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("consumerGroup")),
                        treeMaker.Literal(source.consumerGroup())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("topic")),
                        treeMaker.Literal(source.topic())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("selectorType")),
                        treeMaker.Select(treeMaker.Ident(names.fromString("SelectorType")), names.fromString(source.selectorType().name()))),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("selectorExpression")),
                        treeMaker.Literal(source.selectorExpression())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("nameServer")),
                        treeMaker.Literal(source.nameServer())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("customizedTraceTopic")),
                        treeMaker.Literal(source.customizedTraceTopic())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("enableMsgTrace")),
                        treeMaker.Literal(source.enableMsgTrace())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("secretKey")),
                        treeMaker.Literal(source.secretKey())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("accessKey")),
                        treeMaker.Literal(source.accessKey())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("consumeTimeout")),
                        treeMaker.Literal(source.consumeTimeout())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("consumeThreadMax")),
                        treeMaker.Literal(source.consumeThreadMax())),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("messageModel")),
                        treeMaker.Select(treeMaker.Ident(names.fromString("MessageModel")), names.fromString(source.messageModel().name()))),
                treeMaker.Assign(
                        treeMaker.Ident(names.fromString("consumeMode")),
                        treeMaker.Select(treeMaker.Ident(names.fromString("ConsumeMode")), names.fromString(source.consumeMode().name())))

        );
    }
}
